package ar.com.larreta.entidades;

import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.SQLDelete;


@Entity
@Table(name = "region")
//Borrado logico - Nunca elimina nada
@SQLDelete (sql="DELETE Region WHERE descripcion='NO_BORRAR'")
public class Region extends Dato {

	private TipoRegion tipoRegion;
	private Set<Region> regiones;
	private Region padre;

	@ManyToOne (fetch=FetchType.LAZY)
	@JoinColumn (name="idRegionPadre")
	public Region getPadre() {
		return padre;
	}

	public void setPadre(Region padre) {
		this.padre = padre;
	}

	@OneToMany (mappedBy="padre", fetch=FetchType.LAZY)
	public Set<Region> getRegiones() {
		return regiones;
	}

	public void setRegiones(Set<Region> regiones) {
		this.regiones = regiones;
	}

	@ManyToOne (fetch=FetchType.LAZY)
	@JoinColumn (name="idTipoRegion")
	public TipoRegion getTipoRegion() {
		return tipoRegion;
	}

	public void setTipoRegion(TipoRegion tipoRegion) {
		this.tipoRegion = tipoRegion;
	}
	
}
